home *** CD-ROM | disk | FTP | other *** search
- Path: news.clark.net!not-for-mail
- From: gusty@clark.net (Harlan Messinger)
- Newsgroups: comp.lang.c++
- Subject: Re: overiding c++ stream classes anyone?
- Date: 23 Jan 1996 17:29:02 GMT
- Organization: Clark Internet Services, Inc., Ellicott City, MD USA
- Message-ID: <4e35su$sq4@clarknet.clark.net>
- References: <4cqbja$62n@earth.njcc.com> <4e1d5f$5en@news02.comp.pge.com>
- NNTP-Posting-Host: explorer.clark.net
- Mime-Version: 1.0
- Content-Type: TEXT/PLAIN; charset=ISO-8859-1
- Content-Transfer-Encoding: 8bit
- X-Newsreader: TIN [UNIX 1.3 950726BETA PL0]
-
- Phillip Knight (psk3@pge.com) wrote:
- : I have pulled the last hair out of my head and still have not solved this
- : problem:
- :
- : class X : public ostream {
- : public:
- : ...
- : X& operator<<(X& (*f)(X&)) { return (*f)(*this); }
- : };
- :
- :
- : X& newl(X& os) {
- : cerr << "this never gets printed" << endl;
- : }
-
- This function needs to return something (presumably foo).
-
- :
- : main() {
- : X foo;
- : foo << "test one";
- : foo << endl;
- :
- : foo << "test two" << endl;
- : }
- :
- : so the problem is simple: how do i get my manipulator newl to be called?
-
- By calling it, no? You're calling endl in main(). Don't you mean to use
- newl instead?
-
- foo << newl;
- foo << "test two" << newl;
-
-
-